package com.skyline.common.tag;

import javax.servlet.jsp.JspException;

import org.apache.commons.lang.StringUtils;
import org.apache.taglibs.standard.tag.common.core.OutSupport;

/**
 * 用法类似c:out，但是value不支持Reader接口实现类，而且会产生标签不匹配问题，请慎用。
 * */
public class SummaryOutTag extends OutSupport {
	private static final long serialVersionUID = -8631300846567183992L;
	private int length;

	public SummaryOutTag() {
		super();
	}
	
	public void setValue(Object value) {
		this.value = value;
	}

	// for tag attribute
	public void setDefault(String def) {
		this.def = def;
	}

	// for tag attribute
	public void setEscapeXml(boolean escapeXml) {
		this.escapeXml = escapeXml;
	}
	
	public void setLength(int length) {
		this.length = length;
	}

	@Override
	public int doStartTag() throws JspException {
		if(value != null) {
			String strValue = value.toString();
			value = StringUtils.abbreviate(strValue, length+3);
		}
		return super.doStartTag();
	}
	
	
}
